<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../react18/react.development.js"></script>
  <script src="../react18/react-dom.development.js"></script>
  <script src="../react18/babel.min.js"></script>
</head>

<body>
  <div id="app"></div>
  <script type="text/babel">
    
    class Parent extends React.Component{
      state ={
        name:'高高'
      }
      render(){
        const {name} = this.state
        return(
          <div>
            <h1>我是父组件</h1>
            <button onClick={this.handle}>8325</button>
            <h1>{name}</h1>
            <hr/>
            <Child a={name}/>
          </div>
        )
      }
      handle=()=>{
        const {name} = this.state
        this.setState({
          name:'师父'
        })
      }
    }
    class Child extends React.Component{

      render(){
        // this.props.a+='和脏张'//props对象及内部的属性都是只读的!!!!!! 禁止修改
        let {a} = this.props//当把props解构出来以后,我们可以修改解构出来的变量
        a = a +  '和脏脏'
        return(
          <h1>{a}</h1>
        )
      }
    }
    const root= ReactDOM.createRoot(document.getElementById('app')).render(<Parent/>)


  </script>
</body>

</html>